﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class BaseData_ExpressCompanyPOP : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Init_Info();
        }
    }
    private void Init_Info()
    {
        if (Request.QueryString["code"] != null)
        {
            lbl_code.Text = Request.QueryString["code"].ToString();
            Model.TRANER traner = new BLL.TRANER().GetModel(Request.QueryString["code"].ToString());
            lbl_name.Text = traner.TRANER_NAME;
            if (Request.QueryString["id"] != null)
            {
                Hid_id.Value = Request.QueryString["id"].ToString();
                Model.TRANERCOST cost = new BLL.TRANERCOST().GetModel(lbl_code.Text, Hid_id.Value);
                Tbx_Fweight.Text = cost.TC_FWEIGHT.ToString("f");
                Tbx_Fprice.Text = cost.TC_FWEIGHTPRICE.ToString("f");
                Tbx_Eweight.Text = cost.TC_NWEIGHT.ToString("f");
                Tbx_Eprice.Text = cost.TC_NWEIGHTPRICE.ToString("f");
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Tbx_Fweight.Text.Length < 1)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('请输入首重!')", true);
            return;
        }
        if (Tbx_Fprice.Text.Length < 1)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('请输入首重价格!')", true);
            return;
        }
        if (Tbx_Eweight.Text.Length < 1)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('请输入续重!')", true);
            return;
        }
        if (Tbx_Eprice.Text.Length < 1)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('请输入续重价格!')", true);
            return;
        }
        if (new BLL.TRANERCOST().TranCost_Insert(lbl_code.Text.Trim(), Hid_id.Value, decimal.Parse(Tbx_Fweight.Text.Trim()), decimal.Parse(Tbx_Fprice.Text.Trim()), decimal.Parse(Tbx_Eweight.Text.Trim()), decimal.Parse(Tbx_Eprice.Text.Trim())))
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "", "window.opener.document.location.reload();window.close()", true);
        }
        else
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('保存失败!')", true);
        }
    }
}
